<template>
  <div class="form-login-body">
    <div class="form-login-box">
      <p style="font-size: 32px">表单填报系统</p>
      <div>
        <p class="form-login-title">账号密码登录</p>
        <div class="form-login-input" style="margin-bottom: 24px">
          <a-input v-model:value="userInfo.username" placeholder="账号" size="large">
            <template #prefix>
              <user-outlined style="color: #8c8c8c"/>
            </template>
          </a-input>
        </div>
        <div class="form-login-input">
          <a-input
            v-model:value="userInfo.password"
            placeholder="请输入密码"
            :type="isPassWord ? 'password' : 'text'"
            size="large"
          >
            <template #prefix>
              <lock-outlined style="color: #8c8c8c"/>
            </template>
            <template #suffix>
              <eye-outlined style="color: #8c8c8c" v-if="isPassWord" @click="isPassWord = !isPassWord"/>
              <eye-invisible-outlined style="color: #8c8c8c" v-else @click="isPassWord = !isPassWord"/>
            </template>
          </a-input>
        </div>
        <a-button size="large" @click="doLogin">登 录</a-button>
        <div class="form-login-state">
          <a-checkbox>记住登录状态</a-checkbox>
          <span>忘记密码</span>
        </div>
        <p class="form-login-ts">
          温馨提示：登录账号密码由超级管理员创建、保管
        </p>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useStore } from '@/store/store'
import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'

import { EyeInvisibleOutlined, EyeOutlined, LockOutlined, UserOutlined } from '@ant-design/icons-vue'
import { UsernamePasswordToken } from '@/config/common'

const store = useStore()
const router = useRouter()

const isPassWord = ref(true)
const userInfo = reactive<UsernamePasswordToken>({
  username: '',
  password: ''
})

const doLogin = () => {
  // store.dispatch('Login', { ...userInfo }).then(() => {
  //   store.dispatch('GetInfo').then(() => {
  //     router.push('/')
  //   })
  // })
}
</script>

<style lang="less" scoped>
.form-login-body {
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;

  .form-login-box {
    > span {
      display: block;
      margin-bottom: 20px;

      > img {
        display: block;
        margin: 0 auto;
      }
    }

    > p {
      font-size: 20px;
      line-height: 19px;
      text-align: center;
      color: #fff;
      margin-bottom: 32px;
      font-weight: 300;
    }

    > div {
      width: 440px;
      background: #ffffff;
      box-shadow: 0 4px 32px 0 rgba(0, 0, 0, 0.08);
      border-radius: 4px;
      padding: 40px 40px 0;

      .form-login-title {
        line-height: 64px;
        height: 64px;
        border-bottom: 1px solid #f0f0f0;
        margin-bottom: 32px;
        font-size: 18px;
        color: #262626;
      }

      .form-login-input {
        .ant-input {
          border: 1px solid #d9d9d9;
        }
      }

      > button {
        margin-top: 64px;
        width: 100%;
        background: #2ecbaf;
        border-radius: 2px;
        color: #fff !important;
        font-size: 14px;
        border-color: #2ecbaf;
      }

      .form-login-state {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 20px;

        > span {
          cursor: pointer;
        }
      }

      .form-login-ts {
        margin: 70px 0 0;
        border-top: 1px solid #f0f0f0;
        line-height: 64px;
        height: 64px;
        font-size: 12px;
        color: #bfbfbf;
        text-align: center;
      }
    }
  }

  .form-copyright {
    position: fixed;
    font-size: 12px;
    color: #bfbfbf;
    text-align: center;
    line-height: 12px;
    bottom: 32px;
    left: 0;
    right: 0;
    z-index: 2;
  }
}
</style>
<style>
.form-login-input .ant-input {
  border: 1px solid #d9d9d9;
}
</style>
